﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Model;
namespace DAL
{
    public class 系统设置DAL
    {
        public static int AddCaoZuoYuan() {
            string sql = @"insert into dbo.Admins(UserName,UserPwd,UserCompellation)
values(@UserName,@UserPwd,@UserCompellation)";
            List<SqlParameter> list = new List<SqlParameter>()
            {
                new SqlParameter("@UserName",Admins.UserName),
                new SqlParameter("@UserPwd",Admins.UserPwd),
                new SqlParameter("@UserCompellation",Admins.UserCompellation)
            };
            return DBHelper.Update(sql,list.ToArray());
        }
        public static SqlDataReader ChaSouYou()
        {
            string sql = "select UserID,UserCompellation,UserPwd from dbo.Admins";
            return DBHelper.Zhilianshi(sql,null);
        }
        public static SqlDataReader ChaSuoYouVIP() {
            string sql = "select VGName,VGDiscount from dbo.VipGrade";
            return DBHelper.Zhilianshi(sql,null);
        }
        public static int Upd()
        {

            string sql = "Update Admins set UserPwd=@UserPwd,UserCompellation=@UserCompellation where UserID=@UserID";
            List<SqlParameter> list = new List<SqlParameter>()
            {
                     new SqlParameter("@UserPwd",Admins.UserPwd),
                     new SqlParameter("@UserCompellation",Admins.UserCompellation),
                     new SqlParameter("@UserID",Admins.UserID)
              
            };
            return DBHelper.Update(sql, list.ToArray());
        }
        public static int Del() {
            string sql = @"delete dbo.Admins
where UserID=@UserID";
            List<SqlParameter> list = new List<SqlParameter>()
            {
                new SqlParameter("@UserID",Admins.UserID)
            };
            return DBHelper.Update(sql,list.ToArray());
        }
    }
}
